//
// Created by dddgzc on 2025/1/23.
//

#ifndef PLAYERSELECTIONSCENE_H
#define PLAYERSELECTIONSCENE_H
#include "Animation.h"
#include "Scene.h"
#include "Content.h"
#include "SceneManager.h"
#include "DrawUtils.h"
#include "Player.h"
#include <cstdio>

#include "MainMenuScene.h"
#include "PeashooterPlayer.h"
#include "SunflowerPlayer.h"

class SunflowerPlayer;
class PeashooterPlayer;
extern Atlas* sunflowerIdleRightAtlas;
extern Atlas* peashooterIdleRightAtlas;

extern SceneManager* sceneManager;
extern SDL_Texture* selectorBackground;
extern SDL_Texture* selectorTip;
extern SDL_Texture* vs;
extern SDL_Texture* gravestone;
extern SDL_Texture* avatarPeashooter;
extern SDL_Texture* avatarSunflower;
extern SDL_Texture* sunflowerSelectorBackground;
extern SDL_Texture* peashooterSelectorBackground;
extern SDL_Texture* player1pDesc;
extern SDL_Texture* player2pDesc;
extern SDL_Texture* player1p;
extern SDL_Texture* player2p;
extern SDL_Texture* selectorTip;

extern SDL_Texture* player1pSelectorBtnDown;
extern SDL_Texture* player1pSelectorBtnIdle;
extern SDL_Texture* player2pSelectorBtnDown;
extern SDL_Texture* player2pSelectorBtnIdle;

extern Player* player01;
extern Player* player02;

extern SDL_Texture* player01Avatar;
extern SDL_Texture* player02Avatar;


class PlayerSelectionScene : public Scene {
public:
    PlayerSelectionScene() = default;
    ~PlayerSelectionScene() = default;

    // 场景进入时
    void onEnter() override;
    // 渲染时
    void onDraw(const Camera& camera) override;
    // 数据更新
    void onUpdate(int delta) override;
    // 按键输入
    void onInput(const SDL_Event &e) override;
    // 场景退出时
    void onExit() override;

    enum class SelectPlayerType {
        PEASHOOTER = 0,
        SUNFLOWER,
        INVALID
    };

private:
    int leftScrollImageMiddleLineX = 0;
    int rightScrollImageMiddleLineX = 0;
    int scrollImageHeight = 0;
    int scrollImageWidth = 0;

    SelectPlayerType leftPlayerType; // 默认左侧是太阳花
    SelectPlayerType rightPlayerType; // 默认右侧是豌豆射手

    SDL_Texture* leftScrollBackground = nullptr;
    SDL_Texture* rightScrollBackground = nullptr;

    Animation peashooterIdleAnimation;
    Animation sunflowerIdleAnimation;

    Animation* leftPlayerAnimation = nullptr; // 左边角色的动画
    Animation* rightPlayerAnimation = nullptr; // 右边角色的动画

    SDL_Point leftPlayerAnimationPosition;
    SDL_Point rightPlayerAnimationPosition;
    SDL_Point enterKeyTextPosition;
};



#endif //PLAYERSELECTIONSCENE_H
